package com.test;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.HorizontalScrollView;
import android.widget.ScrollView;

public class test extends Activity {
    /** Called when the activity is first created. */
	private int currentX; 
	  private int currentY; 
	  

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        final ScrollView scroll = (ScrollView)findViewById(R.id.imagescroll);
        scroll.setOnTouchListener(new OnTouchListener() {
			
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				// TODO Auto-generated method stub
				switch(event.getAction()) {
					case MotionEvent.ACTION_DOWN:
						currentX = (int) event.getRawX();
						currentY = (int) event.getRawY();
						break;
					case MotionEvent.ACTION_MOVE:
						int x = (int) event.getRawX();
						int y = (int) event.getRawY();
						scroll.smoothScrollBy(currentX-x, currentY-y);
						break;
				}
				return false;
			}
		});
        
    	HorizontalScrollView hScroll = (HorizontalScrollView)findViewById(R.id.hscroll);
    	hScroll.setOnTouchListener(new OnTouchListener() {
			
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				// TODO Auto-generated method stub
				switch(event.getAction()) {
				case MotionEvent.ACTION_DOWN:
					currentX = (int) event.getRawX();
					currentY = (int) event.getRawY();
					break;
				case MotionEvent.ACTION_MOVE:
					int x = (int) event.getRawX();
					int y = (int) event.getRawY();
					scroll.smoothScrollBy(currentX-x, currentY-y);
					break;
			}
				return false;
			}
		});
    }
}